---
title: bud.globSync
description: Globbing function
tags:
  - filesystem
  - helpers
---

Search for matching files. This function is synchronous but there is an asynchronous version provided by [bud.glob](/reference/bud.glob). The asynchronous version should be preferred.

## Usage

To look for files relative to the project root:

```js
const results = bud.globSync('**/*.json')
```

To include additional search terms you can either treat the function as variadic or specify with an array:

```js
const results = bud.globSync('**/*.json', '**/*.yml')
```

or:

```js
const results = bud.globSync(['**/*.json', '**/*.yml'])
```

This function is compatible with the base handles used with [bud.path](/reference/bud.path).

So, the following would search for `js` files within the **@src** directory:

```js
const results = bud.globSync('@src/**/*.js')
```

## Syntax

You can specify assets using [fast-glob syntax](https://git.io/JkGbw).

- `*` matches any number of characters, but not `/`
- `?` matches a single character, but not `/`
- `**` matches any number of characters, including `/`, as long as it's the only thing in a path part
- `{}` allows for a comma-separated list of "or" expressions
- `!` at the beginning of a pattern will negate the match
